<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<%@ page import="schoolsource.sql.SchoolDBSQL" %>
<%@ page import="schoolsource.model.*" %>
<%@ page import="schoolsource.gui.*" %>
<%@ page import="schoolsource.security.SecurityToken" %>
<% SecurityToken st = (SecurityToken) request.getAttribute(FormFields.SESSION);
   String requestObject = (String) st.getValue(FormFields.TOKEN);
   String name = (String) st.getValue(SchoolDBSQL.USRFNAME) + " " + (String) st.getValue(SchoolDBSQL.USRLNAME);
   ClassContainer classC[] = (ClassContainer[]) st.getValue("classContainer");
   int classnum = (new Integer((String) st.getValue(FormFields.CLASSNUM))).intValue();
   HomeworkContainer homeworkC[] = (HomeworkContainer[]) st.getValue("homeworkContainer"); 
   GradeContainer gradeC[] = (GradeContainer[]) st.getValue("gradeContainer");
   ContactContainer commC[] = (ContactContainer[]) st.getValue("communicationContainer");
   UserContainer teacherContainer = (UserContainer) st.getValue("teacherContainer");
   UserContainer studentWhoSentMail[] = (UserContainer[]) st.getValue("studentWhoSentMail"); 
   String displayMessage = (String) st.getValue("displayMessage"); 
   String loginType = (String) request.getAttribute(FormFields.USRTYPE); 
   String schoolName = (String) request.getAttribute(FormFields.SCHOOLNAME);
   st.putValue("displayMessage", "");
   SchoolContainer sc = SchoolContainer.getSchoolContainer(st.getValue(FormFields.SCHOOLNAME).toString());
   
   String activeMenuBar = sc.getSchoolActiveMenuBarColor().toString();
   String inactiveMenuBar = sc.getSchoolInactiveMenuBarColor().toString();
   String activeLink = sc.getSchoolActiveLinkColor().toString();
   String inactiveLink = sc.getSchoolInactiveLinkColor().toString();
   String headingColor = sc.getSchoolMenuHeadingColor().toString();
   String headingFont = sc.getSchoolHeadingFont().toString();
   String backgroundColor = sc.getSchoolMenuBackgroundColor().toString();
   String schoolLogo = sc.getSchoolLogo().toString();
   String schoolLogoWidth = sc.getSchoolLogoWidth().toString();

 %>

<!-- DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" -->
<HTML>
  <HEAD>
    <SCRIPT>
    
      var state = 0;
      var selecteditem = -1;
      
      function getProperties(x) {
        var outtext = "";
        var counter = 0;
        for (var i in x) {
          outtext = outtext + "*** " + i + ": " + x[i] + "\n";
          if (counter > 4) {
            if (!confirm(outtext)) { return; }
              outtext = "";
              counter = 0;
          }
          else {
            counter = counter + 1;
          }
        }
        if (outtext != "") {
          confirm(outtext);
        }
      }

      function switchGif(x) {
        x.src="../pics/openenvelope.gif";
      }

      function notify(x) {
          alert(x);
      }

      function refresh() {
          top.frames.mainframe.submitPage(top.frames.mainframe.document,"Refresh", -1);
      }

      function init() {
        top.frames.mainframe.initializeViewFrame(top.frames.viewframe);
        top.frames.mainframe.initializeMenuFrame(top.frames.menuframe);
        top.frames.mainframe.updateMenu();
        if ("<%= displayMessage %>" != "null" && "<%= displayMessage %>" != "") {
          top.frames.mainframe.notify("<%= displayMessage %>");
          top.frames.mainframe.refresh();
        }
      }

      function initializeViewFrame(w) {
        var d = w.document;
        d.write("    <HTML><HEAD></HEAD>\n");
        d.write("    <BODY>\n");
        
        d.write("      <center><B>View Area<B></center>\n");
        d.write("      <FORM NAME=\"initialTCIFrame\" METHOD=\"POST\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.CURRENT %>\" VALUE=\"<%= FormFields.SUBFRAME %>\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.TOKEN %>\" VALUE=\"<%= requestObject%>\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.USRTYPE %>\" VALUE=\"<%= loginType %>\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.PARAMETER %>\" VALUE=\"\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.LINKCLICKED %>\" VALUE=\"\">\n");
        d.write("        <INPUT TYPE=\"HIDDEN\" NAME=\"<%= FormFields.CLASSNUM %>\" VALUE=\"<%= classnum %>\">\n");
        d.write("      </FORM>\n");
        d.write("<p>&nbsp;\n");
        d.write("<p>&nbsp;\n");
        d.write("<p>&nbsp;\n");
        d.write("    </BODY></HTML>\n");
        d.close();
      }

      function initializePrintFrame(w, originalText) {
        var d = w.document;
//        originalText = originalText.replace(/<\!\-\-noPrint\-\->(^<\!\-\-\/noPrint\-\->|.|\n)*<\!\-\-\/noPrint\-\->/gim, "");
//        originalText = originalText.replace(/<input .*hidden[^>]*>/gim, "");
//        originalText = originalText.replace(/<input .*type\=submit[^>]*>/gim, "");
//        originalText = originalText.replace(/<input .*type\=button[^>]*>/gim, "");
//        originalText = originalText.replace(/<input .*type\=radio[^>]*>/gim, "");
//        originalText = originalText.replace(/<textarea .*>(.*)<\/textarea>/gim, "$1");
//        originalText = originalText.replace(/<input [^>]*value ?\= ?"([^"]*)"[^>]*>/gim, "$1");
//        originalText = originalText.replace(/<input [^>]*value ?\= ?([^ ]*)[^>]*>/gim, "$1");
//        originalText = originalText.replace(/<input [^>]*>/gim, "");
        d.write("    <HTML><HEAD></HEAD>\n");
        d.write(originalText);
        d.write("</HTML>\n");
        d.close();
      }

      function initializeMenuFrame(w) {
        var d = w.document;
        d.write("    <HTML><HEAD>\n");
        d.write(" </HEAD><BODY style=\" COLOR: <%= headingColor %>; background:<%=backgroundColor%>; position:relative; left:0;\">");
        
        d.write("<DIV><IMG src=\"../pics/<%= schoolLogo %>\" <%= ("".equals(schoolLogoWidth)) ? "width='80%'" : "width=" + schoolLogoWidth + ";" %> style=\"border:0;white-space:nowrap;\"><br><br>");
        d.write("      <FONT SIZE=\"4\" COLOR=\"<%= headingColor %>\" ><B><%= teacherContainer.getFirstName().toString() + " " + teacherContainer.getLastName().toString()%></B></FONT><br>");
        d.write("      <FONT COLOR=\"<%= headingColor %>\">ID: <%= teacherContainer.getSchoolID().toString() %></FONT><br>");
        d.write("      </DIV>");

        d.write("      <div name=\"mailmenu\" id=\"mailmenu\" ");
        d.write("           STYLE=\"padding:1;color:<%= headingColor %>;position:relative;\n");
        d.write("           font-family:sans-serif;left:0;\n" );
        d.write("           font-size:12;width:100;white-space:nowrap;\"><B> Messages</B>\n");
        d.write("      <div name=\"newmail\" id=\"newmail\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 2, \"<%= FormFields.MAILLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.MAILLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>New</a></div>\n");
        d.write("      <div name=\"replymail\" id=\"replymail\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick=\"top.frames.mainframe.go(this, 0, '<%= FormFields.REPLY %>', top.frames.mainframe.getSelected());\">");
        d.write("           <a id=\"<%= FormFields.REPLY %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick=\"return false;\">Reply</a></div>\n");
        d.write("      <div name=\"deletemail\" id=\"deletemail\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick='top.frames.mainframe.deleteMail(this, 0, \"<%= FormFields.DELMAIL %>\");'>");
        d.write("           <a id=\"<%= FormFields.DELMAIL %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Delete</a></div>\n");
        d.write("      </div>");
        d.write("      <div name=\"hwmenu\" id=\"hwmenu\" ");
        d.write("           STYLE=\"padding:1;color:<%= headingColor %>;position:relative;\n");
        d.write("           font-family:sans-serif;left:0;\n" );
        d.write("           font-size:12;width:100;white-space:nowrap;\"><B> Homework</B>\n");
        d.write("      <div name=\"newhw\" id=\"newhw\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;");
        d.write("           height:20;left:10;width:50;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 5, \"<%= FormFields.HWLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.HWLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>New</a></div>\n");
        d.write("      <div name=\"gradehw\" id=\"gradehw\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 5, \"<%= FormFields.GRADELINK %>\", top.frames.mainframe.getSelected());'>");
        d.write("           <a id=\"<%= FormFields.GRADELINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Grade</a></div>\n");
        d.write("      <div name=\"deletehw\" id=\"deletehw\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.deleteHomework(this, 0, \"<%= FormFields.DELHOMEWORK %>\");'>");
        d.write("           <a id=\"<%= FormFields.DELHOMEWORK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Delete</a></div>\n");
        d.write("      </div>");
        d.write("      <div name=\"mainmenu\" id=\"mainmenu\" ");
        d.write("           STYLE=\"padding:1;color:<%= headingColor %>;position:relative;\n");
        d.write("           font-family:sans-serif;left:0;\n" );
        d.write("           font-size:12;width:100;white-space:nowrap;\"><B>Services</B>\n");
        d.write("      <div name=\"profile\" id=\"profile\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 7, \"<%= FormFields.PROFILELISTLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.PROFILELISTLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Student Profile</a></div>\n");
        d.write("      <div name=\"progress\" id=\"progress\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 7, \"<%= FormFields.PROGRESSLISTLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.PROGRESSLISTLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Progess Report</a></div>\n");
        d.write("      <div name=\"attendance\" id=\"attendance\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 7, \"<%= FormFields.ATTENDANCESUMMARY %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.ATTENDANCESUMMARY %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Class Attendance</a></div>\n");
        d.write("      <div name=\"print\" id=\"print\" STYLE=\"padding:1;color:<%= inactiveLink %>;position:relative;");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.goNewWindow(this, \"<%= FormFields.PRINTLINK %>\", \"-1\");'>");
        d.write("           <a id=\"<%= FormFields.PRINTLINK %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= inactiveLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" ");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" ");
        d.write("               onClick='return false;'>Print</a></div>\n");
        d.write("      <div name=\"refresh\" id=\"refresh\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;\n");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.refresh();'>\n");
        d.write("           <a id=\"<%= FormFields.REFRESH %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\"  ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\" \n");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\" \n");
        d.write("               onClick=\"return false;\">Refresh</a></div>\n");
        d.write("      <div name=\"changepw\" id=\"changepw\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;\n");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.go(this, 5, \"<%= FormFields.CHANGEPASSWORD %>\", \"-1\");'>\n");
        d.write("           <a id=\"<%= FormFields.CHANGEPASSWORD %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\" ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\"\n");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\"\n");
        d.write("               onClick='return false;'>Change Password</a></div>\n");
        d.write("      <div name=\"logout\" id=\"logout\" STYLE=\"padding:1;color:<%= activeLink %>;position:relative;\n");
        d.write("           height:20;left:10;white-space:nowrap;\" onClick='top.frames.mainframe.submitPage(top.frames.mainframe.document,\"<%= FormFields.LOGOUT %>\", -1);'>\n");
        d.write("           <a id=\"<%= FormFields.LOGOUT %>\" href=\"\" STYLE=\"text-decoration:none;color:<%= activeLink %>;\"  ");
        d.write("               onMouseOver=\"top.frames.mainframe.makebold(this);\"\n");
        d.write("               onMouseOut=\"this.style.fontWeight='normal';\"\n"); 
        d.write("               onClick='return false;'>Logout</a></div>\n");
        d.write("      </div>\n");
        d.write("    </BODY></HTML>\n");
        d.close();
      }

    var tableReference = null;
//    var messageTableReference = null;
//    var hqtTableReference = null;
   
    function getTable() {
    
        if (tableReference == null) {
            tableReference = getNodeRecursive(document.body, 'maintable');
        }
        
        return tableReference;
    }
      
//    function getMessageTable() {
//    
//        if (messageTableReference == null) {
//            messageTableReference = getNodeRecursive(document.body, 'messageTable');
//        }
//        
//        return messageTableReference;
//    }
      
//    function getHqtTable() {
//    
//        if (hqtTableReference == null) {
//            hqtTableReference = getNodeRecursive(document.body, 'hqtTable');
//        }
//        
//        return hqtTableReference;
//    }
      
    function setTableWidth() {
        getTable().width = getScreenWidth();
//        getMessageTable().width = getScreenWidth()/2;
//        getHqtTable().width = getScreenWidth()/2;
    }
      
    function getNodeRecursive(parent, id) {
        var result = null;
        var listofnodes = parent.childNodes;
        for (var i = 0;i < listofnodes.length; i++) {
            if (listofnodes.item(i).id == id) {
                return listofnodes.item(i);
            }
            else {
                result = getNodeRecursive(listofnodes[i], id);
                if (result != null) {
                    return result;
                }
            }
        }
        return result;
    }
    
    function getScreenWidth(){
        if (screen.width > 800) {
          return 630;
        }
        else {
          return 630;
        }
      }

      function getNode(listofnodes, nodename) {
        var i = 0;
        for (var i = 0;i < listofnodes.length; i++) {
            if (listofnodes.item(i).id == nodename) {
                return listofnodes[i];
            }
        }
      }

      function blankouterframes() {
          top.frames.viewframe.document.write("<HTML><HEAD></HEAD><BODY></BODY></HTML>");
          top.frames.viewframe.document.close();
          top.frames.menuframe.document.write("<HTML><HEAD></HEAD><BODY></BODY></HTML>");
          top.frames.menuframe.document.close();
      }

      function makebold(k) {
        if (k.style.color == "<%= activeLink %>") {
          k.style.fontWeight = 'bold';
        }
      }
      
      function go(k, newstate, option, param) {
        var temp = getNode(k.childNodes, option);
        if (temp.style.color != "<%= activeLink %>")  {
          return false;
        }
        state = newstate;
        updateMenu();
        if (option != null && param != null) {
          goToNextPage(option, param);
        }
      }
      
      function goNewWindow(k, option, param) {
        var temp = getNode(k.childNodes, option);
        if (temp.style.color != "<%= activeLink %>")  {
          return;
        }
        if (option != null && param != null) {
      //    getProperties(top.frames.viewframe.document.body.innerHTML);
          var w = window.open('','4087996','width=640,height=480,resizeable=1,status=1,scrollbars=1,menubar=1');    
      
          initializePrintFrame(w, top.frames.viewframe.document.body.innerHTML);
      
        }
      }
      
      function submitPage(d, linkclicked, val) {
          if (linkclicked == "<%= FormFields.LOGOUT %>") {
              blankouterframes();
          }
          d.forms[0].<%= FormFields.LINKCLICKED %>.value = linkclicked;
          d.forms[0].<%= FormFields.PARAMETER %>.value = val;
          d.forms[0].submit();
      }
      
      function setSelected(k) {
        selectedItem = k;
      }
  
      function getSelected() {
        return top.frames.mainframe.selectedItem;
      }

      function deleteMail(a, b, c){
        if (getNode(a.childNodes, "<%= FormFields.DELMAIL %>").style.color != "<%= activeLink %>") {
          return false;
        }
        if (confirm("Are you sure you want to delete this message?")){
            go(a,b,c,getSelected());
        }
      }
      
      function deleteHomework(a, b, c){
        if (getNode(a.childNodes, "<%= FormFields.DELHOMEWORK %>").style.color != "<%= activeLink %>")  {
          return false;
        }
        if (confirm("Are you sure you want to delete this homework?")){
            go(a,b,c,getSelected());
        }
      }
      
      function goToNextPage(linkclicked, val) {
          var d = top.frames.viewframe.document;
          d.forms[0].<%= FormFields.LINKCLICKED %>.value = linkclicked;
          d.forms[0].<%= FormFields.PARAMETER %>.value = val;
          d.forms[0].submit();
      }
      
      function deletetoken() {
          document.forms[0].submit();
      }

      function contract(k) {
        var nextSib = k.nextSibling;
        k.style.border = "none";
        while (nextSib != null && nextSib.style != null && nextSib.style.posLeft != 0 && 
               nextSib.style.posLeft < (k.style.posLeft + k.clientWidth)) {
          nextSib.style.clip = "rect(auto " + nextSib.style.clipWidth + "px auto auto)";
          nextSib = nextSib.nextSibling;
        }
        k.style.clip = "rect(auto " + k.style.clipWidth + "px auto auto)";
        k.style.overflow = "hidden";
      }

      function expand(k) {
        var additionalSpace = 5;
        var nextSib = k.nextSibling;
        var newClip = 0;
        k.style.overflow = "visible";
        k.style.borderWidth = 1;
        k.style.borderColor = "black";
        k.style.borderStyle = "solid";
        while (nextSib != null && nextSib.style != null && nextSib.style.posLeft >= k.style.posLeft &&
          nextSib.style.posLeft < (k.style.posLeft + k.clientWidth + additionalSpace)) {
          if ((k.style.posLeft + k.clientWidth + additionalSpace) > 
            (nextSib.style.posLeft + nextSib.clientWidth)) {
              newClip = nextSib.clientWidth;
          }
          else {
            newClip = additionalSpace + k.style.posLeft + k.clientWidth - nextSib.style.posLeft;
          }
          nextSib.style.clip = "rect(auto " + nextSib.style.clipWidth + "px auto " + newClip + "px)";
          nextSib = nextSib.nextSibling;
       }
       k.style.clip = "rect(auto auto auto auto)";
     }


     var highlighteddiv = null;

     function highlight(k,l) {
       var nextdiv = k.parentNode.firstChild;
       if (l == "HW") {
         state = 4;
       }
       else if (l == "Mail") {
         state = 1;
       }
       if (highlighteddiv != null) {
           highlighteddiv.style.background = "#FFFFFF";
       }
       highlighteddiv = k;
       k.style.background = "#EEEEEE";
         updateMenu();
     }
   
     function updateMenu() {
         var mainmenu = getNode(top.frames.menuframe.document.body.childNodes, "mainmenu");
         var mailmenu = getNode(top.frames.menuframe.document.body.childNodes, "mailmenu");
         var hwmenu = getNode(top.frames.menuframe.document.body.childNodes, "hwmenu");
   //      var utilmenu = getNode(top.frames.menuframe.document.body.childNodes, "utilmenu");
         var changepw = getNode(getNode(mainmenu.childNodes, "changepw").childNodes, "<%= FormFields.CHANGEPASSWORD %>");
         var refresh = getNode(getNode(mainmenu.childNodes, "refresh").childNodes, "<%= FormFields.REFRESH %>");
         var logout = getNode(getNode(mainmenu.childNodes, "logout").childNodes, "<%= FormFields.LOGOUT %>");
         var newmail = getNode(getNode(mailmenu.childNodes, "newmail").childNodes, "<%= FormFields.MAILLINK %>");
         var replymail = getNode(getNode(mailmenu.childNodes, "replymail").childNodes, "<%= FormFields.REPLY %>");
         var deletemail = getNode(getNode(mailmenu.childNodes, "deletemail").childNodes, "<%= FormFields.DELMAIL %>");
         var newhw = getNode(getNode(hwmenu.childNodes, "newhw").childNodes, "<%= FormFields.HWLINK %>");
         var gradehw = getNode(getNode(hwmenu.childNodes, "gradehw").childNodes, "<%= FormFields.GRADELINK %>");
         var deletehw = getNode(getNode(hwmenu.childNodes, "deletehw").childNodes, "<%= FormFields.DELHOMEWORK %>");
         var printitem = getNode(getNode(mainmenu.childNodes, "print").childNodes, "<%= FormFields.PRINTLINK %>");
         var profile = getNode(getNode(mainmenu.childNodes, "profile").childNodes, "<%= FormFields.PROFILELISTLINK %>");
         var progress = getNode(getNode(mainmenu.childNodes, "progress").childNodes, "<%= FormFields.PROGRESSLISTLINK %>");
         var attendance = getNode(getNode(mainmenu.childNodes, "attendance").childNodes, "<%= FormFields.ATTENDANCESUMMARY %>");
       // state 0 is nothing selected
       if (state == 0) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       // state 1 is mail selected
       else if (state == 1) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= activeLink %>";
           deletemail.style.color = "<%= activeLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       // state 2 is creating new mail
       else if (state == 2) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       // state 3 is replying
       else if (state == 3) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       // state 4 is hw selected
       else if (state == 4) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= activeLink %>";
           deletehw.style.color = "<%= activeLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       // state 5 is creating new hw
       else if (state == 5) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= inactiveLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       // state 6 is entering grades for hw
       else if (state == 6) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
       else if (state == 7) {
         changepw.style.color = "<%= activeLink %>";
         refresh.style.color = "<%= activeLink %>";
         logout.style.color = "<%= activeLink %>";
         printitem.style.color = "<%= activeLink %>";
         if (<%= classnum %> == -2 || <%= classnum %> == -1) {
           newmail.style.color = "<%= inactiveLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= inactiveLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= inactiveLink %>";
           progress.style.color = "<%= inactiveLink %>";
           attendance.style.color = "<%= inactiveLink %>";
         }
         else {
           newmail.style.color = "<%= activeLink %>";
           replymail.style.color = "<%= inactiveLink %>";
           deletemail.style.color = "<%= inactiveLink %>";
           newhw.style.color = "<%= activeLink %>";
           gradehw.style.color = "<%= inactiveLink %>";
           deletehw.style.color = "<%= inactiveLink %>";
           profile.style.color = "<%= activeLink %>";
           progress.style.color = "<%= activeLink %>";
           attendance.style.color = "<%= activeLink %>";
         }
       }
     }

    </SCRIPT>
  </HEAD>
  <BODY onLoad="init();setTableWidth();" onResize()="setTableWidth();">
    <FORM NAME="teacherclassinfoform" METHOD="POST">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.CURRENT %>" VALUE="<%= FormFields.TEACHERCLASSINFO %>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.TOKEN %>" VALUE="<%= requestObject%>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.PARAMETER %>" VALUE="">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.LINKCLICKED %>" VALUE="">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.CLASSNUM %>" VALUE="<%= classnum %>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.SCHOOLNAME %>" VALUE="<%= schoolName %>">
      <INPUT TYPE="HIDDEN" NAME="<%= FormFields.USRTYPE %>" VALUE="<%= loginType %>">
    </FORM>
    <SPAN STYLE="font-size:11;position:absolute; top:0px; left:0;background-color: <%=backgroundColor%>; width:100%;">
    <LEFT>
       <%
       out.print("<a STYLE=\"color:"+headingColor+";font-size:13;position:absolute; top:0px;left:0;background-color:"+ backgroundColor+"; font-family:times roman;\">&gt;&gt;<I>my</I>ClassList&nbsp&nbsp</a><HR>");
       %>
    </LEFT>
      <CENTER>
      <% 
        if (classnum == -2 || classnum == -1) { // TODO Change -2 to some static constant
           out.print("<a STYLE=\"position:relative;padding-left:5;padding-right:5;font-weight:bold;vertical-align:top;text-decoration:none;color:" + inactiveMenuBar + ";font-family:"+ headingFont +";\" type=\"text\" href=\"\" onClick='return false;'>");
           out.print("Today's Updates</a>");
        }
        else {
           out.print("<a STYLE='position:relative;text-decoration:none;color:"+activeMenuBar+";font-family:"+ headingFont +";' type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.TEACHERCLASSINFO + "\", " + -2 + "); return false;'>");
           out.print("Today's Updates</a>");
        }
        if (classnum != -1){
	        out.print("&nbsp<B STYLE=\"color:white;\">|</B>&nbsp");
	    }

        for (int i = 0; i < classC.length-1; i++) {
           if (classnum == i){
             out.print("<a STYLE=\"padding-left:5;padding-right:5;font-weight:bold;text-decoration:none;color:" + inactiveMenuBar + ";font-family:"+ headingFont +";\" type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.TEACHERCLASSINFO + "\", " + i + "); return false;'>");
             out.print(" "+ classC[i].getAssociatedCourse().getCourseShortName().toString()+" ");
           }
           else{
             out.print("<a STYLE=\"text-decoration:none;color:" + activeMenuBar + ";font-family:"+ headingFont +";\" type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.TEACHERCLASSINFO + "\", " + i + "); return false;'>");
             out.print(" "+ classC[i].getAssociatedCourse().getCourseShortName().toString()+" ");
           }
           out.print("</a>&nbsp<B STYLE=\"color:white;\">|</B>&nbsp");
         }

         int ii = classC.length-1;
         if (ii > -1) {
             if (classnum == ii){
               out.print("<a STYLE=\"font-weight:bold;text-decoration:none;color:" + inactiveMenuBar + ";font-family:"+ headingFont +";\" type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.TEACHERCLASSINFO + "\", " + ii + "); return false;'>");
               out.print(" "+ classC[ii].getAssociatedCourse().getCourseShortName().toString()+" ");
               out.print("</a>");
             }
             else{
               out.print("<a STYLE=\"text-decoration:none;color:" + activeMenuBar + ";font-family:"+ headingFont +";\" type=\"text\" href=\"\" onClick='submitPage(top.frames.mainframe.document,\"" + FormFields.TEACHERCLASSINFO + "\", " + ii + "); return false;'>");
               out.print(" "+ classC[ii].getAssociatedCourse().getCourseShortName().toString()+" ");
               out.print("</a>");
             }
         }
      %>
    <HR>
    </CENTER>
    </SPAN>
<!-- <SPAN style="position:absolute; top:60;"> -->
<BR>&nbsp;
<DIV style="position:relative; top:10">
  <CENTER>
    <FONT STYLE="font-size:13;font-family:<%=headingFont%>;">
      <B>
        <% 
          if (classnum == -2) {
            out.println("Today's Updates");
            out.println("<BR>");
            out.println("&nbsp;");
            out.println("<BR>");
          }
          else if (classnum != -1) {
            out.println(classC[classnum].getAssociatedCourse().getCourseShortName().toString());
            out.println("<BR>");
          }
          else {
            out.println("");
          }
        %>
      </B>
      <FONT STYLE="font-size:11;">
        <B>
          <%
            if (classnum == -2) {
              out.println("");
            }
            else if (classnum != -1) {
              out.println(classC[classnum].getClassTime().toString());
            }
            else {
              out.println("<a>NO CLASSES AVAILABLE</a>");
            }
          %>
        </B>
      </FONT>
    </FONT>
  </CENTER>
  </DIV>
  <DIV>
  <CENTER>
  <TABLE style="position:relative;top:10;left:0;font-family:sans-serif;"id='maintable'>
    <TR>
      <TH ALIGN="LEFT">
         <DIV STYLE="font-size:11;font-family:<%=headingFont%>;width:318px"><B>Messages</B></DIV>
      </TH>
      <TH ALIGN="RIGHT">
         <DIV STYLE="font-size:11;font-family:<%=headingFont%>;width:327px"><B>Homework, Quizzes, and Tests</B></DIV>
      </TH>
    </TR>
    <TR>
      <TD ALIGN="LEFT">
      <%
      // TODO fix envelope change from read to unread on click
      // TODO fix highlighting
      Style style = new Style(120, 318);
      style.setHeightType("px");
      style.setWidthType("px");
      ListBox listBox = new ListBox(style);
      Column firstColumn = new Column(new Header(""), 25);
      Column secondColumn = new Column(new Header("From"), 50);
      Column thirdColumn = new Column(new Header("Subject"), 120);
      Column fourthColumn = new Column(new Header("Date Sent"), 100);
      
      firstColumn.setContent(new ImageContent(commC, new String[] {"getHidden"}, GifMaps.getMailMap(), GifMaps.getDefaultMailGif()));
      secondColumn.setContent(new Content(studentWhoSentMail, new String[] {"getLastName"}));
      thirdColumn.setContent(new Content(commC, new String[] {"getMessage", "getSubject"}));
      fourthColumn.setContent(new Content(commC, new String[] {"getMessage", "getDateTimeSent"}));
      
      listBox.addColumn(firstColumn);
      listBox.addColumn(secondColumn);
      listBox.addColumn(thirdColumn);
      listBox.addColumn(fourthColumn);
      out.println(listBox.display());
      %>
      </TD>
      <TD ALIGN="LEFT">
              <div style="position:absolute;border-color:#000000;border-width:1px;border-style:solid;overflow:auto;width:327px;height:120px">
                <div STYLE="position:absolute;top:0;left:35;clip:rect(auto 175px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Description</B></div>
                <div STYLE="position:absolute;top:0;left:185;clip:rect(auto 75px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Assigned</B></div>
                <div STYLE="position:absolute;top:0;left:245;clip:rect(auto 75px auto auto);font-size:10;font-family:<%=headingFont%>;"><B>Due</B></div>
                <br>
                <% if (homeworkC != null){ 
                     String titleText;
                     for (int i = 0; i < homeworkC.length; i++) {
                       titleText = homeworkC[i].getShortName().toString() + "   " + homeworkC[i].getDateAssigned().toString() + "   " + homeworkC[i].getDateDue().toString();
                       out.println("<div TITLE=\"" + titleText + "\" STYLE=\"padding:1;position:absolute;top:"+((i+1)*1.5)+"em;left:0;width:300;white-space:nowrap;\"  onClick=\"highlight(this,'HW');setSelected(" + i + ");goToNextPage('" + FormFields.HWLINK + "', getSelected());\"><IMG src=\"../pics/book.gif\" width=18; border=0>");

                        if(homeworkC[i].getAttachments().length != 0)
                            out.print("<IMG src=\"../pics/paperclip.gif\" width=15;border=0>&nbsp;");


                       out.println("<div STYLE=\"padding:1;color:blue;position:absolute;top:0em;left:35;font-size:10;width:125;white-space:nowrap;overflow:hidden;clipWidth:125;\"><a href=\"\" onClick='return false;'>\n"+
                           DisplayString.getTruncatedString(homeworkC[i].getShortName().toString(), 150, 4) + "</a></div>");
                       out.println("<div STYLE=\"padding:1;color:blue;position:absolute;top:0em;left:185;font-size:10;width:60;white-space:nowrap;overflow:hidden;clipWidth:60;\"><a href=\"\" onClick='return false;'>\n"+
                           DisplayString.getTruncatedString(homeworkC[i].getDateAssigned().toString(), 60, 4) + "</a></div>");
                       out.println("<div STYLE=\"padding:1;color:blue;position:absolute;left:245;top:0em;font-size:10;width:60;white-space:nowrap;overflow:hidden;clipWidth:60;\"><a href=\"\" onClick='return false;'>\n"+
                           DisplayString.getTruncatedString(homeworkC[i].getDateDue().toString(), 70, 4) + "</a></div>");
                       out.println("</div>&nbsp;");
                     }
                   }%>
              </div>
      </TD>
    </TR>

    <TR>
<!--
lines commented out, 9/25/05
    	<TD ALIGN="LEFT">
    		<DIV STYLE="position:relative;top:121;left:20;font-size:10;font-family:<%=headingFont%>;">
      			Select messages to display: 
				<SELECT STYLE="font-size:10;font-family:<%=headingFont%>;">
					<OPTION VALUE="SENTRECEIVED" SELECTED>Sent/Received</OPTION>
				    <OPTION VALUE="SENT">Sent</OPTION>
				    <OPTION VALUE="RECEIVED">Received</OPTION>
			    </SELECT>
		    </DIV>
		</TD>
    	<TD ALIGN="RIGHT">
    		<DIV STYLE="position:relative;top:121;right:20;font-size:10;font-family:<%=headingFont%>;">
      			Select term: 
				<SELECT STYLE="font-size:10;font-family:<%=headingFont%>;">
					<OPTION VALUE="FIRSTTERM" SELECTED>First Quarter</OPTION>
				    <OPTION VALUE="SECONDTERM">First Semester</OPTION>
				    <OPTION VALUE="THIRDTEMM">Second Semester</OPTION>
			    </SELECT>
		    </DIV>
		</TD>
	</TR>
-->
  </table>
  </CENTER>
  </DIV>
  </BODY>
</HTML>



